<template>
    <div>
        <navtitle title="分类" />
        <van-row>
            <van-col span="6">
                <van-sidebar v-model="active">
                    <van-sidebar-item v-for="item in categoriesApiData" :title="item.cat_name" />
                </van-sidebar>
            </van-col>
            
            <van-col span="18">
                <van-skeleton title :row="20" row-width="[100%]" v-if="gstatus"/>
                <div v-for="item in categoriesApiData[active]?.children" v-else>
                    <h4>{{ item.cat_name }}</h4>
                    <router-link :to="{ name: 'code', params: { query: item.cat_name } }">
                        <van-grid :column-num="4">
                            <van-grid-item v-for="item in item.children" :icon="item.cat_icon" :text="item.cat_name" />
                        </van-grid>
                    </router-link>

                </div>
            </van-col>
        </van-row>
    </div>
</template>

<script setup>
import navtitle from '@/components/navtitle.vue';
import { ref } from 'vue'
import { categoriesApi } from '@/api/api'
const categoriesApiData = ref([])
const gstatus=ref(true)
categoriesApi().then((res) => {
    console.log('分类', res);
    categoriesApiData.value = res.data.message
    if(categoriesApiData.value>0){
        gstatus.value=true
    }else{
        gstatus.value=false
    }
})
const active = ref(0);

</script>

<style lang="scss" scoped></style>